<!DOCTYPE html>
<?php

require('htmlHelpers.php');

require('HtmlGen/lib.htmlgen.php');

define( 'MAX_IBU', 50 );
define( 'MAX_ABV', 10.0 );

h::set_indent_pattern("     ");

$tapData = array( GetTapSummary( 0 ), GetTapSummary( 1 ) );


h::html( function() use ( $tapData )
{
    h::head( function()
    {
        h::title( "Raun's Bar - Keg Tracker" );
        h::meta( array( "charset"=>"UTF-8" ) );

        h::script( array( "type"=>"text/javascript", "src"=>"jQuery/1.7.2.jQuery.js" ) );
        h::script( array( "type"=>"text/javascript", "src"=>"Coolclock/coolclock.js" ) );

        h::link( array( "rel"=>"stylesheet",  "href"=>"global2.css" ) );
    } );

    h::body( function() use ( $tapData )
    {
        h::div( array( "class"=>"content" ), function()
        {
            h::h1( "Raun's Bar - Keg Tracker" );
        } );

        //h::div( function() use ( $tapData )
        //{

            h::table( function() use ( $tapData )
            {
                h::tbody( function() use ( $tapData )
                {

                    h::tr( function() use ( $tapData )
                    {
                        h::td( array( "style"=>"width:40%" ), function() use ( $tapData )
                        {
                            $beer = $tapData[0]['beername'];
                            $abv = $tapData[0]['abv'];
                            $kegType = $tapData[0]['kegname'];
                            $ibu = $tapData[0]['ibu'];
                            $description = $tapData[0]['description'];
                            $style = $tapData[0]['style'];
                            $tapDate = date("jS \of F Y", $tapData[0]['tapepochdate'] );

                            h::h3( array( "class"=>"whatsontap" ), "What's on Tap 1?" );
                            h::h3( array( "class"=>"beername" ), "$beer" );
                            h::br();
                            h::h4( array( "class"=>"beerdescription" ), "$description" );
                            h::br();
                            h::h3( array( "class"=>"beertapdate" ), "Tapped on: $tapDate" );
                        } );

                        h::td( array( "colspan"=>"2", "class"=>"clock"), function()
                        {
                            h::div( array( "class"=>"clock", "id"=>"transparent" ), function()
                            {
                                h::canvas( array( "class"=>"CoolClock:swissRailRaun:120:::showDigital", "width"=>"100px", "height"=>"100px" ), function()
                                {
                                } );
                            } );
                        } );

                        h::td( array( "style"=>"width:40%" ), function() use ( $tapData )
                        {
                            $beer = $tapData[1]['beername'];
                            $abv = $tapData[1]['abv'];
                            $kegType = $tapData[1]['kegname'];
                            $ibu = $tapData[1]['ibu'];
                            $description = $tapData[1]['description'];
                            $style = $tapData[1]['style'];
                            $tapDate = date("jS \of F Y", $tapData[1]['tapepochdate'] );

                            h::h3( array( "class"=>"whatsontap" ), "What's on Tap 2?" );
                            h::h3( array( "class"=>"beername" ), "$beer" );
                            h::br();
                            h::h4( array( "class"=>"beerdescription" ), "$description" );
                            h::br();
                            h::h3( array( "class"=>"beertapdate" ), "Tapped on: $tapDate" );
                        } );
                    } );


                    h::tr( function()
                    {
                        h::td( function()
                        {
                            h::p( "Details - Tap 1" );
                        } );

                        h::td( function()
                        {
                            $temperatureData =  GetRecentTempertureData();
                            $temperatureData = array_pop( $temperatureData );

                            $temperature = number_format( $temperatureData[1], 1, '.', '' );
                            
                            h::h3( "Cooler" );
                            h::h3( "$temperature" . " F");

                        } );

                        h::td( function()
                        {
                            h::h3( "Ambient" );
                            h::h3( "???" );
                        } );

                        h::td( function()
                        {
                            h::p( "Details - Tap 2" );
                        } );
                    } );

                } );
            } );
        //} );
    } );
} );

?>